package com.itheima.a_cookie;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/cookieDemo1")
public class CookieDemo1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //创建coolie
        Cookie cookie = new Cookie("username", "zhangsan");
        Cookie cookie2 = new Cookie("username2", "lisi");
        //设置存活时间 1周
        cookie2.setMaxAge(60*60*24*7);
        //响应会浏览器
        response.addCookie(cookie);
        response.addCookie(cookie2);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
